<?php
namespace jy_jdk;
defined('BY_JYA') or exit('error');
/*
	任务
*/
class task extends \plugin{
	/*
		更新短地址
	*/
	public function urlup($id=false){
		$set=$this->plugin_setting('basic');
		$params=array('uniacid'=>$_SESSION['uniacid'],'createtime <'=>time()-5*30*24*3600);
		if(!$id){
			$params['id']=$id;
		}
		$goods = pdo_getall('jy_pddke_goods',$params,array('id','we_app_web_view_short_url'));
		if($goods){
			foreach($goods as $item){
					$re=$this->model()->geturl($item['we_app_web_view_short_url'],$set['unionid']);
					$item['url']=$re['we_app_web_view_short_url'];
					pdo_update('jy_pddke_goods',array('url'=>$re['we_app_web_view_short_url'],'createtime'=>time()),array('id'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
			}
		}
	}
	/*
	   定时获取新订单
	*/
	public function orderup($id=false){
		$set=$this->plugin_setting('basic');
		$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>'taobao','createtime >'=>time()-60);
		$order = pdo_get('jy_weishopke_order',$params,array('id'));
		if(empty($order)){
			$this->model('model')->getorder();
			foreach($orders as $params){
				$this->model('model')->createorder($params);
			}
		}
	}
	/*
	   行获取新订单
	*/
	public function orderrowup($pageIndex=1){
		$set=$this->plugin_setting('basic');
		$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>'taobao','createtime >'=>time()-60);
		$order = pdo_get('jy_weishopke_order',$params,array('id'));
		if(empty($order)){
			$orders=$this->model('model')->getorderrow($pageIndex);
			foreach($orders as $params){
				$this->model('model')->createorder($params);
			}
		}
	}
}